<!-- 搜索表单 -->
<template>
  <el-form label-width="84px" @keyup.enter="search">
    <el-row :gutter="8">
      <el-col :lg="8" :md="8" :sm="12" :xs="24">
        <el-form-item label="字典数据名">
          <el-input
            v-model.trim="form.name"
            clearable
            placeholder="请输入"
          />
        </el-form-item>
      </el-col>
      <el-col :lg="8" :md="8" :sm="12" :xs="24">
        <el-form-item label="字典数据值">
          <el-input
            v-model.trim="form.code"
            clearable
            placeholder="请输入"
          />
        </el-form-item>
      </el-col>
      <el-col :lg="8" :md="8" :sm="12" :xs="24">
        <el-form-item label-width="16px">
          <el-button type="primary" @click="search">
            查询
          </el-button>
          <el-button @click="reset">
            重置
          </el-button>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script setup>
import { useFormData } from '@/utils/use-form-data'

const emit = defineEmits(['search'])

/** 表单数据 */
const { form, resetFields } = useFormData({
  name: '',
  code: '',
})

/** 搜索 */
function search() {
  emit('search', form)
}

/**  重置 */
function reset() {
  resetFields()
  search()
}

defineExpose({ resetFields })
</script>
